﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MISAPP.MISInterface;

public partial class View_WMG_WMG002_1 : ViewMatrix
{
    string tym = string.Empty;
    string captionRight = string.Empty;
    string captionLeft = string.Empty;
    bool isBorder0px = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "存款分析";
        criteriaList = new string[] { "Criteria" };
        serviceName = "MISAPP.Classify.Service.Service_WMG002";
        //List<iSelectList> CriteriaList = Session["Criteria"] as List<iSelectList>;
        //iSelectList selectYM = CriteriaList[0] as iSelectList;
        //string[] yms = selectYM.GetListArray();
        captionRight ="單位:百萬元";
        //captionLeft = string.Format("WMG {0} 存款分析"
        //    , Utility.GetTaiwanYM(yms[0]));
        setCaptionLeft();
        tym = Utility.GetNewGridViewCaption(captionLeft, captionRight);
        if (!IsPostBack)
        {
            getData();
        }
    }

    protected void getData()
    {
        System.Data.DataTable dt = GetDataFromSerevice("GetSummaryData");
        CLB_Summary.Caption = tym;
        CLB_Summary.SetData(dt, new string[] { });
    }

    protected void btn2Excel_Click(object sender, EventArgs e)
    {
        serviceName = "MISAPP.Classify.Service.Service_WMG002";
        criteriaList = new string[] { "Criteria" };

        FillToSession();
        
        string pageParameter;
        pageParameter = string.Format(
            "method=GetSummaryData&xls=WMG002&service=Service_WMG002&caption={0}&captionRight={1}&toHtmlMethod={2}"
            , captionLeft, captionRight, "wmg002ToHtmlTable");


        btn2Excel.PreviousPage = "../GV2XLS.aspx";
        btn2Excel.PageParameter = pageParameter;
    }

    protected void CLB_Summary_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            switch (e.Row.Cells[3].Text)
	        {
                case "台幣活期":
                case "台幣定期":
                case "台幣活存比":
                    isBorder0px = true;
                    e.Row.CssClass = "Border0px";
                    for (int i = 0; i < e.Row.Cells.Count; i++)
                    {
                        e.Row.Cells[i].CssClass = "Border0px";
                    }
                    break;
		        default:
                    if (isBorder0px == true)
                    {
                        e.Row.CssClass = "Border0px";
                        for (int i = 0; i < e.Row.Cells.Count; i++)
                        {
                            e.Row.Cells[i].CssClass = "Border0px";
                        }
                    }
                break;
	         }

        }
    }

    protected void setCaptionLeft()
    {
        List<iSelectList> CriteriaList = Session["Criteria"] as List<iSelectList>;
        int pos = 0;
        if (CriteriaList.Count.Equals(2))
        {
            pos = 1;
        }
        iSelectList selectYM = CriteriaList[pos] as iSelectList;
        string[] yms = selectYM.GetListArray();
        captionLeft = string.Format("WMG {0} 存款分析"
            , pos.Equals(0) ? Utility.GetTaiwanYM(yms[0])
            :yms[0].ToString() );
    }
}
